package com.bdqn.t330.ch04.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bdqn.t330.ch04.entity.User;
import com.bdqn.t330.ch04.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImp implements UserService {

    @Resource
    UserMapper userMapper;


    @Override
    public List<User> getList(Integer id) {
        List<User> users = null;
        QueryWrapper queryWrapper = new QueryWrapper();
        //eq(boolean condition, R column, Object val);
        //select * from sys_user
        if (id == null) {
            users = userMapper.selectList(null);
        } else {
            queryWrapper.eq(true, "usr_id", id);
            users = userMapper.selectList(queryWrapper);
        }
        return users;
    }
}
